

import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class WelcomeVideoWidget extends StatefulWidget {
  const WelcomeVideoWidget({Key? key}) : super(key: key);

  @override
  State<WelcomeVideoWidget> createState() => _WelcomeVideoWidgetState();
}
// 倒计时页面 的视频播放

class _WelcomeVideoWidgetState extends State<WelcomeVideoWidget> {
  // 播放控制器
  VideoPlayerController? _controller;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _controller = VideoPlayerController.network(
        'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4')
    ..initialize().then((value){
      print("开始");
      _controller!.play();
      setState(() {
         
      });
    });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _controller!.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: _controller!.value.isInitialized?
       SizedBox(
         width: MediaQuery.of(context).size.width,
         height: MediaQuery.of(context).size.height,
         child: AspectRatio(
           aspectRatio: _controller!.value.aspectRatio,
           child:VideoPlayer(_controller!),
           ),
       ):Container(),

    );
  }
}